package com.pucong.gitee.database.backup.business.sys.controller;

import com.pucong.gitee.database.backup.business.sys.service.SysLicenceService;
import com.pucong.gitee.database.backup.common.entity.sys.authorize.AuthorizeInfo;
import com.pucong.gitee.database.backup.common.entity.sys.authorize.AuthorizeResult;
import com.pucong.gitee.database.backup.common.entity.sys.authorize.AuthorizeResultDate;
import com.pucong.gitee.database.backup.utils.Res;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author pucong
 * @company gitee.com/pucong
 * @create 2020-12-01
 */
@RestController
@RequestMapping("/sys/authorize")
@Api(value = "系统授权-API ",tags = "04. 系统授权")
public class SysLicenceController {

    @Autowired
    private SysLicenceService sysLicenceService;

    @GetMapping("/isAuthorize")
    @ApiOperation(value = "01校验授权是否有效")
    public Res<AuthorizeResult> isAuthorize(){
        AuthorizeResult authorizeResult = sysLicenceService.isAuthorize();
        return Res.ok(authorizeResult);
    }

    @GetMapping("/getAuthorizeInfo")
    @ApiOperation(value = "02获取授权信息")
    public Res<AuthorizeInfo> getAuthorizeInfo(){
        AuthorizeInfo authorizeInfo = sysLicenceService.getAuthorizeInfo();
        return Res.ok(authorizeInfo);
    }

    @GetMapping("/isAuthorizeExpireDate")
    @ApiOperation(value = "03判断是否还有1个月过期")
    public Res<AuthorizeResultDate> isAuthorizeExpireDate(){
        AuthorizeResultDate aBoolean = sysLicenceService.isAuthorizeExpireDate();
        return Res.ok(aBoolean);
    }
}
